package com.vfa.fishing;


import android.app.Activity;
import android.graphics.Color;

import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.text.ChangeableText;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.font.FontFactory;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.source.AssetTextureSource;
import org.anddev.andengine.opengl.texture.source.ITextureSource;
import org.anddev.andengine.ui.activity.BaseSplashActivity;

public class SplashscreenActivity extends BaseSplashActivity {

	private Font mFont;
	private Texture mFontTexture;
	private ChangeableText mCongratulationsText;
	
    @Override
    protected ScreenOrientation getScreenOrientation() {
        return ScreenOrientation.LANDSCAPE;
    }

    @Override
    protected ITextureSource onGetSplashTextureSource() {
        return new AssetTextureSource(this, "gfx/background_menu.jpg");
    }

    @Override
    protected float getSplashDuration() {
        return 5f;
    }

    @Override
    protected Class<? extends Activity> getFollowUpActivity() {
        return MenuActivity.class;
    }
    
    @Override
    public void onLoadResources() {
    	super.onLoadResources();
        /* Load the font we are going to use. */
        FontFactory.setAssetBasePath("font/");
        this.mFontTexture = new Texture(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        this.mFont = FontFactory.createFromAsset(this.mFontTexture, this, "LCD.ttf", 50, true, Color.RED);
        this.mEngine.getTextureManager().loadTexture(this.mFontTexture);
        this.mEngine.getFontManager().loadFont(this.mFont);

    }

    @Override
    public Scene onLoadScene() {
            final Scene splashScene = super.onLoadScene();
            /* The congratulations text. */
            if (this.mCongratulationsText == null) {
            	this.mCongratulationsText = new ChangeableText(0, 0, this.mFont, "VITALIFY ASIA", "VITALIFY ASIA".length());
            }
            this.mCongratulationsText.setPosition((MenuActivity.CAMERA_WIDTH - this.mCongratulationsText.getWidth()) * 0.5f, (MenuActivity.CAMERA_HEIGHT - this.mCongratulationsText.getHeight()) * 0.5f);
            //this.mCongratulationsText.registerEntityModifier(new ScaleModifier(3, 0.1f, 2.0f));
            //this.mCongratulationsText.registerEntityModifier(new RotationModifier(3, 0, 720));
            splashScene.getLastChild().attachChild(mCongratulationsText);
            return splashScene;
            
           
    }
    
}
